<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	{include="style"}
	<style>
	.layui-form-pane .layui-form-label{
		width:160px;
	}
	</style>

</head>
<body >
  <div class="layui-rows" style="    margin: 10px;">
   <div class="x-nav">
		
		<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont" style="line-height:30px">&#xe6aa;</i></a>
	</div>
    <div class="layui-tab">
	  <ul class="layui-tab-title">
		<li class="layui-this">导入</li>
		<li>导出</li>
	  </ul>
	  <div class="layui-tab-content">
		<div class="layui-tab-item layui-show">
			<div class="row">
		    <form class="layui-form layui-form-pane" method="POST" id="import_form" action="{fun U('Excel/import')}">
			<!--表单必须要携带ID-->
			<input name="id" value="{$plugins['id']}" type="hidden">
			<input name="step" value="1" type="hidden">
			<div class="layui-form-item">
				<label class="layui-form-label">表格格式</label>
				<div class="layui-input-inline">
					<select name="excel_type" lay-verify="">
					  <option value="2005">Excel 2005(后缀为.xls)</option>
					  <option value="2007">Excel 2007(后缀为.xlsx)</option>
					</select> 
				</div>
			  </div>
			<fieldset class="layui-elem-field layui-field-title">
			  <legend>表格样式</legend>
			  <div class="layui-field-box">
					<img style="width:350px" src="/A/exts/jzexcel/tpl/1.jpg" />
					<input type="radio" name="excel_style" title="不带字段" value="1" >
					<img style="width:350px"  src="/A/exts/jzexcel/tpl/2.jpg" />
					<input type="radio" name="excel_style" value="2" title="带字段"  checked>
			  </div>
		
			 <div class="layui-form-item">
				<label class="layui-form-label">上传文件</label>
				<div class="layui-input-inline">
				  <input type="text" name="excel_path" id="excel_path" required  lay-verify="required" placeholder="文件路径" autocomplete="off" class="layui-input">
				   
				</div>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn" id="test1">
					  <i class="layui-icon">&#xe67c;</i>选择文件
					</button>
				</div>
			  </div> 
			<div class="layui-form-item">
				<label class="layui-form-label">选择模块</label>
				<div class="layui-input-inline">
				  <select name="excel_molds" lay-filter="excel_molds"  lay-verify="required">
					
					{loop table="molds" orderby="id asc"  as="v"}
					{if($v['biaoshi']!='page')}
					<option value="{$v['biaoshi']}">{$v['name']}模块({$v['biaoshi']})</option>
					{/if}
					{/loop}
					<option value="newmolds">创建新模块(newmolds)</option>
				  </select>
				</div>
			  </div>
			<div class="layui-form-item" id="molds_name" style="display:none;">
				<label class="layui-form-label">创建模块名</label>
				<div class="layui-input-inline">
				  <input type="text" name="molds_name"    placeholder="请输入中文" autocomplete="off" class="layui-input">
				</div>
			  </div>
			<div class="layui-form-item" id="newmolds" style="display:none;">
				<label class="layui-form-label">创建模块标识</label>
				<div class="layui-input-inline">
				  <input type="text" name="newmolds"    placeholder="请输入英文字母" autocomplete="off" class="layui-input">
				</div>
			  </div>
			 <div class="layui-form-item" style="margin-top:40px;">
				<div class="layui-input-block">
				  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
				  
				</div>
			  </div>
	  
			</form>
			</div>
		
		</div>
		<div class="layui-tab-item">
			<div class="row">
		    <form class="layui-form layui-form-pane" method="get" id="import_form2" action="{fun U('Excel/output')}">
			<div class="layui-form-item">
				<label class="layui-form-label">导出模块</label>
				<div class="layui-input-inline">
				  <select name="output_molds" lay-filter="output_molds"  lay-verify="required">
					
					{loop table="molds" orderby="id asc"  as="v"}
					{if($v['biaoshi']!='page')}
					<option value="{$v['biaoshi']}">{$v['name']}模块({$v['biaoshi']})</option>
					{/if}
					{/loop}
					
				  </select>
				</div>
			</div>
			<div class="layui-form-item" style="margin-top:40px;">
				<div class="layui-input-block">
				  <button class="layui-btn" lay-submit lay-filter="formDemo2">立即提交</button>
				  
				</div>
			  </div>
			
			
			</form>
			</div>
		
		</div>
		
	  </div>
	</div>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  
    
    
 
</form>
</div>

    <script>
         layui.use(['form','upload'], function(){
              var form = layui.form;
             var upload = layui.upload;
              //监听提交
              form.on('submit(formDemo)', function(data){
				//console.log(data.field);return false;
				$("#import_form").submit();
				
                return false;
              });
			  form.on('submit(formDemo2)', function(data){
				//console.log(data.field);return false;
				$("#import_form2").submit();
				
                return false;
              });
			  form.on('select(excel_molds)', function(data){
				  console.log(data.elem); //得到select原始DOM对象
				  console.log(data.value); //得到被选中的值
				  console.log(data.othis); //得到美化后的DOM对象
				  if(data.value=='newmolds'){
					$("#newmolds").show();
					$("#molds_name").show();
				  }else{
					$("#newmolds").hide();
					$("#molds_name").hide();
				  }
				}); 
			  
			   var uploadInst = upload.render({
					elem: '#test1' //绑定元素
					,url: '{fun U('excel/uploads')}' //上传接口
					,accept:'file'
					,exts:'xlsx|xls'
					,done: function(res){
					  //上传完毕回调
					  if(res.code==0){
							 
							 $('#excel_path').val(res.url);
						}else{
							 layer.alert(res.error, {icon: 5});
						}
					  
					}
					,error: function(){
					  //请求异常回调
					}
				  });
							 
			  
			  
            });

		
		 function addone(){
				var html='<tr><td><input placeholder="不带http" type="text" class="layui-input "  name="data_1[]" value=""></td><td><select name="data_2[]" ><option value="0">全局</option><option value="1">电脑端</option><option value="2">手机端</option><option value="3">微信端</option></select></td><td><input type="text" placeholder="不填默认全局" class="layui-input "  name="data_3[]" value=""></td></tr>';
				
				$(".addone").before(html);
				layui.use('form', function(){
				var form = layui.form;
			    form.render();
			  })
				
			 }
			  
	
    </script>

    
 
</body>
</html>